package com.elysia.newsservice.mapper;

import com.elysia.newsservice.domain.dto.VersionJoinDTO;
import com.elysia.newsservice.domain.vo.UpdateLogTotalVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UpdateLogMapper {
    /**
     * 关联查询所有有效版本及对应的更新明细（一次性查全）
     * 注：LEFT JOIN确保即使没有明细的版本也会被查询出来
     */
    @Select("SELECT " +
            "gv.id, " +
            "gv.version, " +
            "gv.update_date, " +
            "gv.update_category, " +
            "vui.type, " +
            "vui.content " +
            "FROM game_version gv " +
            "LEFT JOIN version_update_item vui " +
            "ON gv.id = vui.version_id AND vui.is_deleted = 0 " +
            "WHERE gv.is_deleted = 0 " +
            "ORDER BY gv.update_date DESC, vui.type ASC")
    List<VersionJoinDTO> selectAllUpdateLogs();
}